from django.shortcuts import render
from django.http import HttpResponse,JsonResponse
from rest_framework.views import APIView
from rest_framework.response import Response
from .models import *

# Create your views here.

# 接受来自路由的正则参数
# def info1(request,参数名1，参数名2，……)：

def info1(request, id, page):
    print(f"id={id},page={page}")
    return HttpResponse("OK")


def info2(request, mobile):
    print(f"mobile={mobile}")
    return HttpResponse("OK")


def info3(request, mobile):
    print(f"mobile={mobile}")
    return HttpResponse("OK")


def info4(request, mobile):
    print(f"mobile={mobile}")
    return HttpResponse("OK")


def info5(request, mobile):
    print(f"mobile={mobile}")
    return HttpResponse("OK,info5")


def detail1(request, pk, cat):
    return HttpResponse(f"分类={cat},并id={pk}的实体商品页面")


def detail2(request, pk, cat):
    return HttpResponse(f"分类={cat},并id={pk}的实体商品页面")


def index3(request, id):
    return HttpResponse("<img src='1.png'>")


"""路由转换器"""


def inbuild_reverse(request, num):
    """内置路由转换器"""
    return HttpResponse(f"num={num}")


def inbuild_reverse2(request, content):
    """内置路由转换器"""
    return HttpResponse(f"content={content}")


def inbuild_reverse3(request, ustr):
    """内置路由转换器"""
    return HttpResponse(f"ustr={ustr}")

